/**
 *   ro.dandanciu.webgallery.domainmodel.RegistrationRequest.java [WebGalleryBusiness]
 *   Copyright (C) Jul 19, 2008 - Dan Danciu
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place - Suite 330,
 *   Boston, MA 02111-1307, USA.
 */
package ro.dandanciu.webgallery.domainmodel;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import ro.dandanciu.webgallery.domainmodel.utils.DbConstants;

/**
 * Entity class which defines an registration request.
 *
 * @author Dan Danciu
 */
@Entity
@Table(name = "TA_REG_REQ")
@NamedQueries({
        @NamedQuery(name = "RegistrationRequest.GetByCode",
                query = "select r from RegistrationRequest r where r.code LIKE :code") })
public class RegistrationRequest {

    /**
     * The id of the registration request.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "K_REG_REQ")
    private int id;

    /**
     * The user for which the registration request was done.
     */
    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name = "F_USER")
    private User user;

    /**
     * The code for this registration request.
     */
    @Column(name = "C_CODE", length = DbConstants.RegistrationRequest.CODE_SIZE)
    private String code;

    /**
     * The date the registration request was created.
     */
    @Column(name = "D_REG_REQ")
    private Date requestDate;

    /**
     * Getter for the id.
     * @return the id.
     */
    public final int getId() {
        return id;
    }

    /**
     * Setter for the id.
     * @param id the id to set.
     */
    public final void setId(final int id) {
        this.id = id;
    }

    /**
     * Getter for the user.
     * @return the user.
     */
    public final User getUser() {
        return user;
    }

    /**
     * Setter for the user.
     * @param user the user to set.
     */
    public final void setUser(final User user) {
        this.user = user;
    }

    /**
     * Getter for the code.
     * @return the code.
     */
    public final String getCode() {
        return code;
    }

    /**
     * Setter for the code.
     * @param code the code to set.
     */
    public final void setCode(final String code) {
        this.code = code;
    }

    /**
     * Getter for the requestDate.
     * @return the requestDate.
     */
    public final Date getRequestDate() {
        return requestDate;
    }

    /**
     * Setter for the requestDate.
     * @param requestDate the requestDate to set.
     */
    public final void setRequestDate(final Date requestDate) {
        this.requestDate = requestDate;
    }
}
